/**
 * Created by Administrator on 2016/2/19.
 */

var tab_index=3;
$(function(){
    (new CommMenu()).addSecondaryMenuCss($("#pipeMgr"));
    //场站阀室数据展示
    getValveRoomData();
    //管道数据展示
    getLineData();
    //管段数据展示
    getSegmentData();
    //检测管段数据展示
    getInspSegmentData();
    //场站阀任务的启用及停用
    $("#offRoom").live("click",function(){toOffRoom(1,"停用");});
    $("#onRoom").live("click",function(){toOffRoom(0,"启用");});
    //管道任务的启用及停用
    $("#offLine").live("click",function(){toOffLine(1,"停用");});
    $("#onLine").live("click",function(){toOffLine(0,"启用");});
    //管段任务的启用及停用
    $("#offSegment").live("click",function(){toOffSegment(1,"停用");});
    $("#onSegment").live("click",function(){toOffSegment(0,"启用");});
    //检测管段任务的启用及停用
    $("#offInspSegment").live("click",function(){toOffInspSegment(1,"停用");});
    $("#onInspSegment").live("click",function(){toOffInspSegment(0,"启用");});
    //场站阀室的任务状态修改
    toUpdateStated();
    //管道数据发布
    toUpdateLineStated();
    //管段数据发布
    toUpdateSegmentStated();
    //检测管段发布
    toUpdateInspSegmentStated();
    //单条删除场站阀室数据(含真假删除)
    deletRoomOne();
    //单条删除管道数据(含真假删除)
    deletLineOne();
    //单一删除管段数据(含真假删除)
    deletSegmentOne();
    //单一删除检测管段
    deletInspSegmentOne();
    //场站阀室数据批量删除(含真假删除)
    deleteRoomDate();
    //管道数据批量删除(含真假删除)
    deleteLineDate();
    //管段数据批量删除(含真假删除)
    deleteSegmentDate();
    //检测管段数据批量删除（目前只是假删除）
    deleteInspSegmentData();
    //场站阀室新增
    saveRoomDate();
    //新增管道数据
    saveLineDate();
    //新增管段数据
    saveSegmentDate();
    //新增检测管段数据
    saveInspSegmentDate();
    /*test*/
    saveByInspSegment();
    //管道下拉
    //getLine();
});
$(function(){

    $("#segmentClose").click(function(){
        cleanVal();
    })

    //管道、关闭表单时清空数据
    $("#LineClose").click(function(){
        $("#xzlineName").val("");
        $("#xzlineNum").val("");
        $("#xzqszcfs").children().removeAttr("id");// 起始场站阀室
        $("#xzzdzcfs").children().removeAttr("id");// 终止场站终室
        $("#xzqszcfs").children().html("--请选择--");
        $("#xzzdzcfs").children().html("--请选择--");
    });
    //场站阀室、关闭表单时清空数据
    $("#VRclose").click(function(){
        valveRoomName=$("#zcfsmc").val("");
        valveRoomAbridge=$("#zcfsdh").val("");
        $("#zcfslx a").attr("id","").html("--请选择--");
    });

    $('.on-off').on('click',function(){
        $(this).hasClass('active')?$(this).removeClass('active'):$(this).addClass("active")
    });



    // 切换
    $('.tab-li li').each(function(i){
        $(this).on('click',function(){
            $(this).addClass('active')
            $(this).siblings().removeClass('active')
            $('.sj-main .sj-0').eq(i).removeClass('none')
            $('.sj-main .sj-0').eq(i).siblings().addClass('none')
        })
    });
    $('.set-tab li').each(function(i){
        $(this).on('click',function(){
            $(this).addClass('active')
            $(this).siblings().removeClass('active')
            $('.set-ck .set-t0').eq(i).removeClass('none')
            $('.set-ck .set-t0').eq(i).siblings().addClass('none')
        })
    });


    //场站阀室全选
    findAll(".table-ck .parentSelect i.parentSelect1",".table-ck .childSelect i.childSelect1");
    //管道全选
    findAll(".table-ck .LineParentSelect i.parentSelect2",".table-ck .LineChildSelect i.childSelect2");
    //管段全选
    findAll(".table-ck .SegmentParentSelect i.parentSelect3",".table-ck .SegmentChildSelect i.childSelect3");
    //检测管段全选
    findAll(".table-ck .InspSegmentParentSelect i.parentSelect4",".table-ck .InspSegmentChildSelect i.childSelect4");


})

////////////////          通用部分             //////////////////////////////////////////--%>
//为空验证1
    function validateNun(value){
        return value==null|| value==""||value=="undefined";
    }
//为空验证2
function validateByClass(va){

    var result=true;
    $("input."+va).each(function(){
        var value=trim($(this).val());//数据前后去空
        //alert(value+"--"+value)
        if(value==null|| value==""||value=="undefined")
        {

            if(result){
                alert("请对必填项赋值");
            }
            result=false;
        }

    })
    $("div.dropdown-list."+va).each(function(){
        var id=$(this).find(".checked a").attr("id");
        var value=id;
        if(value==null|| value==""||value=="undefined")
        {

            if(result){
                alert("请选择必选项");
                result=false;
            }
        }
    })
    return result;
}

//js去前后空格
function trim(str){
    str = str.replace(/^(\s|\u00A0)+/,'');
    for(var i=str.length-1; i>=0; i--){
        if(/\S/.test(str.charAt(i))){
            str = str.substring(0, i+1);
            break;
        }
    }
    return str;
}
//全选
function findAll(P,C){
    $(P).live("click",function(){
        if($(P).hasClass("active")){
            $(C).removeClass("active");
        }else{
            $(C).addClass("active");

        }
    });
}
////////////////          物理管段部分             //////////////////////////////////////////
//管段条件查询
    function findBySegmentConditions(){
        var lineNameId=$("#FClineName").children().attr("id");//管道名称id                   
        var segmentName=$("#FCsegmentName").val();
        var segmentAbridge=$("#FCsegmentNum").val();
        var taskStatus=$("#FCSsta").children().attr("value");
        var status=$("#FCsta").children().attr("value");
        allData={"lineNameId":lineNameId,"taskStatus":taskStatus,"status":status,"segmentName":segmentName,"segmentAbridge":segmentAbridge};
        $("#basicSegment").selectDataAfterSetParm(allData);
    }
//新增、修改管段数据
function saveSegmentDate(){
    $("#addPieSegment").click(function(){
        var lineNameId=$("#xzSegmentLineData").children().attr("id");//管道名称id                   
        var fromPipeValveroomId=$("#xzSegmentFVR").children().attr("id");// 起始场站阀室         
        var toPipeValveroomId=$("#xzSegmentTVR").children().attr("id");// 终止场站终室           
        var segmentName=$("#xzSegmentName").val();
        var segmentAbridge=$("#xzSegmentNum").val();
        var id=$("#addPieSegment").val();
        data={"lineNameId":lineNameId,"fromPipeValveroomId":fromPipeValveroomId,"toPipeValveroomId":toPipeValveroomId,"segmentName":segmentName,"segmentAbridge":segmentAbridge,"id":id};
        data2={"lineNameId":lineNameId,"fromPipeValveroomId":fromPipeValveroomId,"toPipeValveroomId":toPipeValveroomId,"segmentName":segmentName,"segmentAbridge":segmentAbridge};
        if($("#addPieSegment").val()!=null&&$("#addPieSegment").val()!=""){
            //编辑
            if(validateByClass("segNotNull")){
                if(toPipeValveroomId==fromPipeValveroomId){
                    alert("起始场站阀室不能与终点场站阀室相同");
                    return;
                }else{
                    resultAjax(p_path+"/settings/pipe/updatePipeSegment.json",
                        data,function(data,obj){
                            $("#cz2").modal("hide");
                            alert(data.message);
                            cleanVal();//清空弹出框
                            getSegmentData();

                            $('.ul-main .set-ul').eq(1).removeclass('none');
                            $('.ul-main .set-ul').eq(1).siblings().addClass('none')
                        },"JSON",$(this));
                }
            }
        }else{
            //新增
            if(validateByClass("segNotNull")){
                if(toPipeValveroomId==fromPipeValveroomId){
                    alert("起始场站阀室不能与终点场站阀室相同");
                    return;
                }else{
                    resultAjax(p_path+"/settings/pipe/addPipeSegment.json",
                        data2,function(data,obj){
                            $("#cz2").modal("hide");
                            alert(data.message);
                            cleanVal();//清空弹出框
                            getSegmentData();

                            $('.ul-main .set-ul').eq(1).removeclass('none');
                            $('.ul-main .set-ul').eq(1).siblings().addClass('none')
                        },"JSON",$(this));
                }
            }
        }
    });
};
//管段单一删除
function deletSegmentOne(){
    //获得id delet1 deleteRoomOne
    $(".deleteSegmentOne").live("click",function(){
        var id=$(this).attr("id");
        var stated=$(this).attr("stated");
        var delFlag = window.confirm("确定要删除吗");
        if(delFlag==true){
            var del=stated;//数据为未发布数据，真删除
            var data={del:del,id:id};
            resultAjax(p_path+"/settings/pipe/removeSegmentById.json",
                data,function(data,obj){
                    getSegmentData();
                    alert("删除成功!");
                },"JSON");
        }
    });

}
//管段批量删除
function deleteSegmentDate(){
    $("#delSegment").click(function(){
        //找到所有class为active的选项
        var ids=new Array();
        $(".table-ck .SegmentChildSelect i.active").each(function(){
            ids.push($(this).attr("id"));
        });
        if(ids.length < 1){
            alert("请先勾选需要删除的任务");
            return ;
        }
        var idss=ids.join();
        var data={"ids":idss};
        var delFlag = window.confirm("确定要删除吗");
        if(delFlag == true){
            var url = p_path+"/settings/pipe/removePipeSegment.json";
            $.ajax({
                url:url,
                type:'post',
                dataType:'json',
                data:data,
                success:function(data){
                    getSegmentData();
                    alert(data.message);
                }
            });
        }
    });
}
//管段任务状态修改（发布）
function toUpdateSegmentStated(){
    $("#updSegmentStated").live("click",function(){
        var ids=new Array();
        $(".table-ck .SegmentChildSelect i.active").each(function(){
            ids.push($(this).attr("id"));
        });
        if(ids.length < 1){
            alert("请先勾选需要发布的任务");
            return ;
        }
        var idss=ids.join();
        var data={"ids":idss};
        var updFlag = window.confirm("确定要发布吗");
        if(updFlag == true){
            var url = p_path+"/settings/pipe/updateSegmentStated.json";
            $.ajax({
                url:url,
                type:'post',
                dataType:'json',
                data:data,
                success:function(data){
                    getSegmentData();
                    alert(data.message);
                }
            });
        }
    })
};


//获得所有的管段数据
function getSegmentData(){
    var column=[
        {title:segmentCheckBoxFormatP,name:"ID_",width:"5%",align:"center",format:segmentCheckBoxFormat},
        // {title:"序号",name:"",width:"10%",align:"center"},
        {title:"管道名称",name:"PPLNAME",width:"15%",align:"center"},
        {title:"管段名称",name:"NAME_",width:"15%",align:"center"},
        {title:"管段代号",name:"ABRIDGE",width:"10%",align:"center"},
        {title:"起始场站阀室",name:"FVRNAME",width:"15%",align:"center"},
        {title:"终止场站阀室",name:"TVRNAME",width:"15%",align:"center"},
        {title:"任务状态",name:"DATA_STATED",width:"8%",align:"center",format:dataStatedFormat},
        {title:"状态",name:"",width:"7%",align:"center",format:segmentStatFormat},
        {title:"编辑 删除",name:"",width:"10%",align:"center",format:deleteFormatBySegment}
    ];
    $('#basicSegment').initTable({
        url:p_path+"/settings/pipe/findByConditionForSegment.json",
        columnData:column,
        selectDataNow:true,
        isBindDataToTr:true,
        onlyFirstPage: true,
        autoCheckBox:false
    });
}
//管段复选框文本代码(perant)
function segmentCheckBoxFormatP(data){
    var ck="<span class=\"table-ck\"><span class=\"check-box selected SegmentParentSelect\" onclick=\"\" id=\"segmentParentSelect\"><i class=\"parentSelect3\"></i></span></span>";
    return ck;
}
//管段复选框文本代码
function segmentCheckBoxFormat(data){
    var ck="<span class=\"table-ck\"><span class=\"check-box selected SegmentChildSelect\" onclick=\"\" id="+data.ID_+"><i class=\"childSelect3\" id="+data.ID_+"></i></span></span>";
    return ck;
}
//管段编辑、删除部分
function deleteFormatBySegment(data){
    var de="<a onclick='editSegment(this)' data-toggle=\"modal\" class=\"edit0\" id="+data.ID_+" stated="+data.DATA_STATED+" href=\"#cz2\"></a><a href=\"javascript:void(0);\"  class=\"delet1 deleteSegmentOne\" id="+data.ID_+" stated="+data.DATA_STATED+"></a>";
    return de;
}
function xgbjgdbt(){
    $("#addPieSegment").val("")
    $("#cz2Title").html("新建管段")
}
//管段编辑部分
function editSegment(a){
    var tr=$(a).parent().parent();
    var json=tr.data("trData");
    $("#cz2Title").html("编辑管段")
    $("#addPieSegment").val(json.ID_);

    $("#xzSegmentName").val(json.NAME_);
    $("#xzSegmentNum").val(json.ABRIDGE);
    //给下拉框赋显示值
    $("#xzSegmentLineData").children().html(json.PPLNAME);
    $("#xzSegmentFVR").children().html(json.FVRNAME);
    $("#xzSegmentTVR").children().html(json.TVRNAME);
    //给编辑的下拉框赋ID值
    $("#xzSegmentLineData").children().attr("id",json.PIPE_LINE_ID);
    $("#xzSegmentFVR").children().attr("id",json.FROM_PIPE_VALVEROOM_ID);
    $("#xzSegmentTVR").children().attr("id",json.TO_PIPE_VALVEROOM_ID);
}
//管段状态切换
function segmentStatFormat(json){
    var acti=json.STATE_;
    var bar="<em test="+acti+" onclick=updateSegmentState('"+json.ID_+"',"+acti+",'"+json.DATA_STATED+"') class=\" "+json.ID_+" on-off "+((acti==null||acti=='0')?"active":"")+" \"></em>";
    return bar;
}
//管段状态切换部分2
function updateSegmentState(id,em,sta){
    var ss=$("."+id).attr("test");
    var s= ss==1 ? 0 : 1;
    //需要将em重新赋值给
    var data={status:s,"ids":id};
    if (id==null){
        alert("没有获取到id");
        return;
    }else if(sta!='20'){
        alert("数据未发布不能启用");
        $('#basicSegment').refresh();
        return;
    }else{
        resultAjax(p_path+"/settings/pipe/updateSegmentS.json",
            data,function(data,obj){
                if(data.result=="1"){
                    $("."+id).hasClass('active')?$("."+id).removeClass('active'):$("."+id).addClass("active");
                    $("."+id).attr("test",s);
                }else{
                    alert("状态修改失败");
                }
                $('#basicSegment').refresh();
            },"JSON");
    }
}

//管段初始化：任务启用及停用
function toOffSegment(_status,m){
    var ids=new Array();
    $(".table-ck .SegmentChildSelect i.active").each(function(){
        ids.push($(this).attr("id"));
    });
    if(ids.length < 1){
        alert("请先勾选任务");
        return ;
    }
    var err=new Array();
    if (ids.length==1){
        var option1 = $("#basicSegment").data("option");
        var tabData=option1.allData;
        for (var i1 in ids){
            for (var i2 in tabData){
                if (ids[i1]==(tabData[i2]["ID_"])){
                    if ((tabData[i2]["DATA_STATED"])!="20"){
                        err.push((tabData[i2]["NAME_"]))
                    }
                }
            }
        }
    }

    if (err.length>0){
        alert("未发布，不能启用。");
        return;
    }
    var idss=ids.join();
    var data={"ids":idss,status:_status};
    resultAjax(p_path+"/settings/pipe/updateSegmentS.json",
        data,function(data,obj){getSegmentData();alert("已选择"+ids.length+"条数据，"+m+data.message); },"JSON");
}
////////////////          管道部分             //////////////////////////////////////////>
//管道条件查询
    function findByLineConditions(){
        var lineName=$("#lineFindName").val();
        var lineAbridge=$("#lineFindNum").val();
        var taskStatus=$("#lineFindDataStatus").children().attr("value");
        var status=$("#lineFindStatus").children().attr("value");
        var allData={"lineName":lineName,"lineAbridge":lineAbridge,"taskStatus":taskStatus,"status":status}
        $("#basicLine").selectDataAfterSetParm(allData);
    }
//新增、修改管道
function saveLineDate(){
    $("#addPieLine").click(function(){
        var lineName=$("#xzlineName").val();// 管道名称                     
        var lineAbridge=$("#xzlineNum").val();// 管道代号                  
        var fromPipeValveroomId=$("#xzqszcfs").children().attr("id");// 起始场站阀室
        var toPipeValveroomId=$("#xzzdzcfs").children().attr("id");// 终止场站终室 
        var id=$("#addPieLine").val();
        var data={"lineName":lineName,"lineAbridge":lineAbridge,"fromPipeValveroomId":fromPipeValveroomId,"toPipeValveroomId":toPipeValveroomId};
        var data2={"lineName":lineName,"lineAbridge":lineAbridge,"fromPipeValveroomId":fromPipeValveroomId,"toPipeValveroomId":toPipeValveroomId,"id":id};
        if($("#addPieLine").val()!=null&&$("#addPieLine").val()!=""){
            //修改
            if(validateByClass("notNull")){
                if(toPipeValveroomId==fromPipeValveroomId){
                    alert("起始场站阀室不能与终点场站阀室相同");
                    return;
                }else{
                    resultAjax(p_path+"/settings/pipe/updateLine.json",
                        data2,function(data,obj){
                            $("#cz1").modal("hide");
                            alert(data.message);
                            cleanVal();//清空弹出框		
                            $("#addPieRoom").val("");
                            getLineData();
                            $('.ul-main .set-ul').eq(1).removeclass('none');
                            $('.ul-main .set-ul').eq(1).siblings().addClass('none');

                        },"JSON",$(this));
                }
            }
        }else{
            //新增
            if(validateByClass("notNull")){
                if(toPipeValveroomId==fromPipeValveroomId){
                    alert("起始场站阀室不能与终点场站阀室相同");
                    return;
                }else{
                    resultAjax(p_path+"/settings/pipe/addPipeLine.json",
                        data,function(data,obj){
                            $("#cz1").modal("hide");
                            alert(data.message);
                            cleanVal();//清空弹出框
                            getLineData();
                           $('.ul-main .set-ul').eq(1).removeclass('none');
                            $('.ul-main .set-ul').eq(1).siblings().addClass('none');
                        },"JSON",$(this));
                }
            }
        }
    })
}
//管道任务状态修改（发布）
function toUpdateLineStated(){
    $("#updLineStated").live("click",function(){
        var ids=new Array();
        $(".table-ck .LineChildSelect i.active").each(function(){
            ids.push($(this).attr("id"));
        });
        if(ids.length < 1){
            alert("请先勾选需要发布的任务");
            return ;
        }
        var idss=ids.join();
        var data={"ids":idss};
        var updFlag = window.confirm("确定要发布吗");
        if(updFlag == true){
            var url = p_path+"/settings/pipe/updateLineStated.json";
            $.ajax({
                url:url,
                type:'post',
                dataType:'json',
                data:data,
                success:function(data){
                    getLineData();
                    alert(data.message);
                }
            });
        }
    })
};

//管道单一删除
function deletLineOne(){
    //获得id delet1 deleteRoomOne
    $(".deleteLineOne").live("click",function(){
        var id=$(this).attr("id");
        var stated=$(this).attr("stated");
        var delFlag = window.confirm("确定要删除吗");
        if(delFlag==true){
            var del=stated;//数据为未发布数据，真删除
            var data={del:del,id:id};
            resultAjax(p_path+"/settings/pipe/removeLineById.json",
                data,function(data,obj){
                    getLineData();
                    alert("删除成功!");
                },"JSON");
        }
    });

}
//管道批量删除
function deleteLineDate(){
    $("#delLine").click(function(){
        //找到所有class为active的选项
        var ids=new Array();
        $(".table-ck .LineChildSelect i.active").each(function(){
            ids.push($(this).attr("id"));
        });
        if(ids.length < 1){
            alert("请先勾选需要删除的任务");
            return ;
        }
        var idss=ids.join();
        var data={"ids":idss};
        var delFlag = window.confirm("确定要删除吗");
        if(delFlag == true){
            var url = p_path+"/settings/pipe/removePipeLine.json";
            $.ajax({
                url:url,
                type:'post',
                dataType:'json',
                data:data,
                success:function(data){
                    getLineData();
                    alert(data.message);
                }
            });
        }
    });
}
//获得所有的管道数据
function getLineData(){
    var column=[
        {title:LineCheckBoxFormatP,name:"ID_",width:"5%",align:"center",format:LineCheckBoxFormat},
        //  {title:"序号",name:"",width:"15%",align:"center"},
        {title:"管道名称",name:"NAME_",width:"15%",align:"center"},
        {title:"管道代号",name:"ABRIDGE",width:"15%",align:"center"},
        {title:"起始场站阀室",name:"PPVNAME",width:"15%",align:"center"},
        {title:"终止场站阀室",name:"PPVVNAME",width:"15%",align:"center"},
        {title:"任务状态",name:"DATA_STATED",width:"8%",align:"center",format:dataStatedFormat},
        {title:"状态",name:"",width:"7%",align:"center",format:lineStatFormat},
        //  {title:"编辑",name:"",width:"5%",align:"center",format:editFormat},
        {title:"编辑 删除",name:"",width:"10%",align:"center",format:deleteFormatByLine}
    ];

    $('#basicLine').initTable({
        url:p_path+"/settings/pipe/findByConditinForLine.json",
        columnData:column,
        selectDataNow:true,
        isBindDataToTr:true,
        onlyFirstPage: true,
        autoCheckBox:false
    });
}
//管道复选框文本代码(perant)
function LineCheckBoxFormatP(data){
    //var data="xifan";
    //console.log(data);
    var ck="<span class=\"table-ck\"><span class=\"check-box selected LineParentSelect\" onclick=\"\" id=\"parentSelect\"><i class=\"parentSelect2\"></i></span></span>";
    return ck;
}
//管道复选框文本代码
function LineCheckBoxFormat(data){
    //console.log(data.ID_);
    var ck="<span class=\"table-ck\"><span class=\"check-box selected LineChildSelect\" onclick=\"\" id="+data.ID_+"><i class=\"childSelect2\" id="+data.ID_+"></i></span></span>";
    return ck;
}
//管道编辑、删除部分
function deleteFormatByLine(data){
    var de="<a onclick='editLine(this)' data-toggle=\"modal\" class=\"edit0\" id="+data.ID_+" stated="+data.DATA_STATED+" href=\"#cz1\"></a><a href=\"javascript:void(0);\"  class=\"delet1 deleteLineOne\" id="+data.ID_+" stated="+data.DATA_STATED+"></a>";
    return de;
}
function xgxjgd(){
    $("#addPieLine").val("");
    $("#cz1Title").html("新建管道");
}
//管道编辑部分
function editLine(a){
    var tr=$(a).parent().parent();
    var json=tr.data("trData");
    initInspSeg();
    $("#cz1Title").html("编辑管道");
    $("#addPieLine").val(json.ID_);

    $("#xzlineName").val(json.NAME_);
    $("#xzlineNum").val(json.ABRIDGE);
    //给下拉框赋显示值
    $("#xzqszcfs").children().html(json.PPVNAME);
    $("#xzzdzcfs").children().html(json.PPVVNAME);
    //给编辑的下拉框赋ID值
    $("#xzqszcfs").children().attr("id",json.FROM_PIPE_VALVEROOM_ID);
    $("#xzzdzcfs").children().attr("id",json.TO_PIPE_VALVEROOM_ID);
}
//管道状态切换
function lineStatFormat(json){
    var acti=json.STATE_;
    var bar="<em test="+acti+" onclick=updateLineState('"+json.ID_+"',"+acti+",'"+json.DATA_STATED+"') class=\" "+json.ID_+" on-off "+((acti==null||acti=='0')?"active":"")+" \"></em>";
    return bar;
}
//管道状态切换部分2
function updateLineState(id,em,sta){
    var ss=$("."+id).attr("test");
    var s= ss==1 ? 0 : 1;
    //需要将em重新赋值给
    var data={status:s,"ids":id};
    if (id==null){
        alert("没有获取到id");
        return;
    }else if(sta!='20'){
        alert("数据未发布不能启用");
        $('#basicLine').refresh();
        return;
    }else{
        resultAjax(p_path+"/settings/pipe/updateLineS.json",
            data,function(data,obj){
                if(data.result=="1"){
                    $("."+id).hasClass('active')?$("."+id).removeClass('active'):$("."+id).addClass("active");
                    $("."+id).attr("test",s);
                }else{
                    alert("状态修改失败");
                }
                $('#basicLine').refresh();
            },"JSON");
    }
}

//管道初始化：任务启用及停用
function toOffLine(_status,m){
    var ids=new Array();
    $(".table-ck .LineChildSelect i.active").each(function(){
        ids.push($(this).attr("id"));
    });
    if(ids.length < 1){
        alert("请先勾选任务");
        return ;
    }

    var err=new Array();
    if (ids.length==1){
        var option1 = $("#basicLine").data("option");
        var tabData=option1.allData;
        for (var i1 in ids){
            for (var i2 in tabData){
                if (ids[i1]==(tabData[i2]["ID_"])){
                    if ((tabData[i2]["DATA_STATED"])!="20"){
                        err.push((tabData[i2]["NAME_"]))
                    }
                }
            }
        }
    }

    if (err.length>0){
        alert("未发布，不能启用。");
        return;
    }

    var idss=ids.join();
    var data={"ids":idss,status:_status};
    resultAjax(p_path+"/settings/pipe/updateLineS.json",
        data,function(data,obj){getLineData();alert("已选择"+ids.length+"条数据，"+m+data.message); },"JSON");
}
////////////////          场站阀室部分             //////////////////////////////////////////-
    //场站阀室条件查询
    function findByVRConditions(){
        //$("#findByVRConditions").live("click",function(){
        var valveRoomName=$("#VRfindName").val();
        var valveRoomAbridge=$("#VRfindNum").val();
        var taskStatus=$("#VRfindDStatus").children().attr("value");
        var status=$("#VRfindStatus").children().attr("value");
        var allData={"valveRoomName":valveRoomName,"valveRoomAbridge":valveRoomAbridge,"taskStatus":taskStatus,"status":status}
        $("#basicVR").selectDataAfterSetParm(allData);
    }
//新增、修改场站阀室
function saveRoomDate(){
    $("#addPieRoom").click(function(){
        //获取输入框的值|| segmentId == "" || segmentId == 
        var valveRoomName=$("#zcfsmc").val();
        var valveRoomAbridge=$("#zcfsdh").val();
        var valveRoomType=$("#zcfslx").children().attr("id");
        var id=$("#addPieRoom").val();
        var data={valveRoomName:valveRoomName,valveRoomAbridge:valveRoomAbridge,valveRoomType:valveRoomType};
        var data2={valveRoomName:valveRoomName,valveRoomAbridge:valveRoomAbridge,valveRoomType:valveRoomType,id:id};
        if($("#addPieRoom").val()!=null&&$("#addPieRoom").val()!=""){
            if(validateByClass("fsnotNull")){
                resultAjax(p_path+"/settings/pipe/updateVR.json",
                    data2,function(data,obj){
                        $("#cz").modal("hide");
                        alert(data.message);
                        cleanVal();
                        id=$("#addPieRoom").val("");
                        getValveRoomData();
                        $('.ul-main .set-ul').eq(1).removeclass('none');
                        $('.ul-main .set-ul').eq(1).siblings().addClass('none');
                        return;
                    },"JSON",$(this));
            }/* else if(validateNun(valveRoomName)){
             alert("场站阀室名不能为空");
             }else if(validateNun(valveRoomAbridge)){
             alert("场站阀室代号不能为空");
             } */
        }else{
            if(validateByClass("fsnotNull")){
                resultAjax(p_path+"/settings/pipe/addPipeValveRoom.json",
                    data,function(data,obj){
                        $("#cz").modal("hide");
                        alert(data.message);
                        cleanVal();
                        getValveRoomData();
                        $('.ul-main .set-ul').eq(1).removeclass('none');
                        $('.ul-main .set-ul').eq(1).siblings().addClass('none');
                    },"JSON",$(this));
            }
        }
    });
}
//场站阀室单一删除
function deletRoomOne(){
    //获得id delet1 deleteRoomOne
    $(".deleteRoomOne").live("click",function(){
        var id=$(this).attr("id");
        var stated=$(this).attr("stated");
        var delFlag = window.confirm("确定要删除吗");
        if(delFlag==true){
            var del=stated;//数据为未发布数据，真删除
            var data={del:del,id:id};
            resultAjax(p_path+"/settings/pipe/removeValveRoomById.json",
                data,function(data,obj){
                    //getValveRoomData();
                    $('#basicVR').refresh();
                    flashMessage_("操作成功")
                    //alert(data);
                },"JSON");
        }
    });

}
//场站阀室批量删除
function deleteRoomDate(){
    $("#delRoom").click(function(){
        //找到所有class为active的选项
        var ids=new Array();
        $(".table-ck .childSelect i.active").each(function(){
            ids.push($(this).attr("id"));
        });
        if(ids.length < 1){
            alert("请先勾选需要删除的任务");
            return ;
        }
        var idss=ids.join();
        var data={"ids":idss};
        var delFlag = window.confirm("确定要删除吗");
        if(delFlag == true){
            var url = p_path+"/settings/pipe/removeValveRoom.json";
            $.ajax({
                url:url,
                type:'post',
                dataType:'json',
                data:data,
                success:function(data){
                    getValveRoomData();
                    alert(data.message);
                }
            });
        }
    });
}
//场站阀室的任务状态修改
function toUpdateStated(){
    $("#updRoomStated").live("click",function(){
        var ids=new Array();
        $(".table-ck .childSelect i.active").each(function(){
            ids.push($(this).attr("id"));
        });
        if(ids.length < 1){
            alert("请先勾选需要发布的任务");
            return ;
        }
        var option1 = $("#basicVR").data("option");
        var tabData=option1.allData;

        var updateIds=new Array();

        for (var i1 in ids){
            for (var i2 in tabData){
                if (ids[i1]==(tabData[i2]["ID_"])){
                    console.info(tabData[i2]);
                    if ((tabData[i2]["DATA_STATED"])!="20"){
                        updateIds.push(tabData[i2]["ID_"]);
                    }
                }
            }
        }
        var idss=ids.join();
        var updateIdss=updateIds.join();
        var data={"ids":idss, "updateIds":updateIdss};
        var updFlag = window.confirm("确定要发布吗");
        if(updFlag == true){
            var url = p_path+"/settings/pipe/updateVRstated.json";
            $.ajax({
                url:url,
                type:'post',
                dataType:'json',
                data:data,
                success:function(data){
                    getValveRoomData();
                    alert(data.message);
                }
            });
        }
    })
};

//场站阀室的任务启用及停用
function toOffRoom(_status,m){
    var ids=new Array();
    $(".table-ck .childSelect i.active").each(function(){
        ids.push($(this).attr("id"));
    });
    if(ids.length < 1){
        alert("请先勾选任务.");
        return ;
    }

    var err=new Array();
    if (ids.length == 1){
        var option1 = $("#basicVR").data("option");
        var tabData=option1.allData;
        for (var i1 in ids){
            for (var i2 in tabData){
                if (ids[i1]==(tabData[i2]["ID_"])){
                    if ((tabData[i2]["DATA_STATED"])!="20"){
                        err.push((tabData[i2]["SHOW_NAME"]))
                    }
                }
            }
        }
    }

    if (err.length>0){
        alert("未发布，不能启用。");
        return;
    }

    var idsCount = ids.length;
    var option1 = $("#basicVR").data("option");
    var tabData=option1.allData;
    for (var i1 in ids){
        for (var i2 in tabData){
            if (ids[i1]==(tabData[i2]["ID_"])){
                if ((tabData[i2]["STATE_"])==_status){
                    ids.splice($.inArray(tabData[i2]["ID_"],ids),1);
                }
            }
        }
    }

    var idss=ids.join();
    var data={"ids":idss,status:_status};
    resultAjax(p_path+"/settings/pipe/updateVRS.json",
        data,[function(data,obj){
            alert("已选择"+idsCount+"条数据，"+m+data.message);
            $('#basicVR').refresh();
            //getValveRoomData();
        },
        function(){
            $('#basicVR').refresh();
            //getValveRoomData();
        }],"JSON");
}


//获得场站阀室数据
function getValveRoomData(){
    var column=[
        {title:checkBoxFormatP,name:"ID_",width:"5%",align:"center",format:checkBoxFormat},
        // {title:"序号",name:"",width:"15%",align:"center"},
        {title:"场站阀室名称",name:"NAME_",width:"20%",align:"center"},
        {title:"场站阀室代号",name:"ABRIDGE",width:"10%",align:"center"},
        {title:"场站阀室类型",name:"TYPE_",width:"10%",align:"center"},
        {title:"任务状态",name:"DATA_STATED",width:"10%",align:"center",format:dataStatedFormat},
        {title:"状态",name:"",width:"10%",align:"center",format:statFormat},
        //  {title:"编辑",name:"",width:"5%",align:"center",format:editFormat},
        {title:"编辑 删除",name:"",width:"13%",align:"center",format:deleteFormat}
    ];

    $('#basicVR').initTable({
        url:p_path+"/settings/pipe/findByConditinForVR.json",
        columnData:column,
        selectDataNow:true,
        isBindDataToTr:true,
        onlyFirstPage: true,
        autoCheckBox:false
    });
}

//场站阀室复选框文本代码(perant)
function checkBoxFormatP(data){
    //var data="xifan";
    //console.log(data);
    var ck="<span class=\"table-ck\"><span class=\"check-box selected parentSelect\" id=\"parentSelect\"><i class=\"parentSelect1\"></i></span></span>";
    return ck;
}
//场站阀室复选框文本代码
function checkBoxFormat(data){
    //console.log(data.ID_);
    var ck="<span class=\"table-ck\"><span class=\"check-box selected childSelect\" onclick=\"\" id="+data.ID_+"><i class=\"childSelect1\" id="+data.ID_+"></i></span></span>";
    return ck;
}

//编辑、删除部分
function deleteFormat(data){
    var de="<a onclick='showTrdata(this)' data-toggle=\"modal\" class=\"edit0\" id="+data.ID_+" stated="+data.DATA_STATED+" href=\"#cz\"></a><a href=\"javascript:void(0);\"  class=\"delet1 deleteRoomOne\" id="+data.ID_+" stated="+data.DATA_STATED+"></a>";
    return de;
}

//场站阀室新增
function initValueRoom(){
    $("#addPieRoom").val("");
    $("#popupTitle").html("新建场站阀室")
}

//场站阀室编辑部分
function showTrdata(a){
    var tr=$(a).parent().parent();
    var json=tr.data("trData");
    $("#popupTitle").html("编辑场站阀室")
    $("#addPieRoom").val(json.ID_);
    $("#zcfsmc").val(json.SHOW_NAME);
    $("#zcfslx a").attr("id","").html("--请选择--");
    var aa=$("#zcfslxUL a[id='"+json.TYPE_ID+"']");
    if (aa!=null){
        $("#zcfslx a").replaceWith(aa.clone());
    }
    // $("#zcfslx").children().html(json.TYPE_);
    $("#zcfsdh").val(json.ABRIDGE);
}
//任务状态数字转化为汉字
function dataStatedFormat(data){
    var id=data.ID_;
    var stat=(data.DATA_STATED=='20')?"已发布":"未发布";
    var re="<i>"+stat+"</i>";
    return re;
}
//场站阀室状态切换
function statFormat(json){
    var acti=json.STATE_;
    var bar="<em test="+acti+" onclick=updateState('"+json.ID_+"',"+acti+",'"+json.DATA_STATED+"') class=\" "+json.ID_+" on-off "+((acti==null||acti=='0')?"active":"")+" \"></em>";
    return bar;
}
//场站阀室状态切换部分2
function updateState(id,em,sta){
    var ss=$("."+id).attr("test");
    var s= ss==1 ? 0 : 1;
    //需要将em重新赋值给
    var data={status:s,"ids":id};
    if (id==null){
        alert("没有获取到id");
        return;
    }else if(sta!='20'){
        alert("数据未发布不能启用");
        $('#basicVR').refresh();
        return;
    }else{
        resultAjax(p_path+"/settings/pipe/updateVRS.json",
            data,[function(data,obj){
                if(data.result=="1"){
                    flashMessage_("修改成功")
                   // $("."+id).hasClass('active')?$("."+id).removeClass('active'):$("."+id).addClass("active");
                    $("."+id).attr("test",s);
                }else{
                    alert("状态修改失败");
                }
                $('#basicVR').refresh();
            },function(){
                $('#basicVR').refresh();
            }],"JSON");
    }
}
//清空弹出框
function cleanVal(){
    $("input.cleanVal").each(function(){
        $(this).val("");
    })
    $("div.dropdown-list.cleanVal").each(function(){
        $(this).find(".checked a").removeAttr("id");
        $(this).find(".checked a").html("--请选择--");
    })
    $("div.dropdown-list.cleanValclean").each(function(){
        //$(this).children().attr("id","");
        $(this).find("ul").empty();
        $(this).find(".checked a").html("--请选择--");
    })
}

////////////////          检测管段部分             //////////////////////////////////////////
//检测管段编辑部分
function editInspSegment(a){
    var tr=$(a).parent().parent();
    var json=tr.data("trData");

$("#jcPopupTitle").html("编辑检测管段");
    $("#inspSegmentListByLine").html('');
    getInsSegByLine(json.PIPE_LINE_ID);
    initInspSeg();
    $("#jcgdID").val(json.ID_);
    $("#jcgdmc").find("a").html(json.PPLNAME);
    $("#jcgdmc").find("a").attr("id",json.PIPE_LINE_ID);
    $("#inspSegmentName").val(json.INSP_SEGMENT_NAME);
    $("#inspSegmentAbridge").val(json.ABRIDGE);

    $("#qsczfs").find("a").html(json.PPVFNAME);
    $("#qsczfs").find("a").attr("id",json.PPVFID);

    $("#fromPiggingStructureDiv").find("a").html(json.PPPFNUM);
    $("#fromPiggingStructureDiv").find("a").attr("id",json.PPPFID);


    $("#zdczfs").find("a").html(json.PPVTNAME);
    $("#zdczfs").find("a").attr("id",json.PPVTID);

    $("#toPiggingStructureDiv").find("a").html(json.PPPTNUM);
    $("#toPiggingStructureDiv").find("a").attr("id",json.PPPTID);
}
//检测管段状态切换
function inspSegmentStatFormat(json){
    var acti=json.STATE_;
    var bar="<em test="+acti+" onclick=updateInspSegmentState('"+json.ID_+"',"+acti+",'"+json.DATA_STATED+"') class=\" "+json.ID_+" on-off "+((acti==null||acti=='0')?"active":"")+" \"></em>";
    return bar;
}
//检测管段状态切换部分2
function updateInspSegmentState(id,em,sta){
    var ss=$("."+id).attr("test");
    var s= ss==1 ? 0 : 1;
    //需要将em重新赋值给
    var data={status:s,"ids":id};
    if (id==null){
        alert("没有获取到id");
        return;
    }else if(sta!='20'){
        alert("数据未发布不能启用");
        $('#basicInspS').refresh();
        return;
    }else{
        resultAjax(p_path+"/settings/pipe/inspSegement/updateInspSegmentS.json",
            data,function(data,obj){
                if(data.result=="1"){
                    $("."+id).hasClass('active')?$("."+id).removeClass('active'):$("."+id).addClass("active");
                    $("."+id).attr("test",s);
                }else{
                    alert("状态修改失败");
                }
                $('#basicInspS').refresh();
            },"JSON");
    }
}

//根据阀室查询所有的收发球装置
function getPiggingStructureByVR(VRid,id){
    data={"id":VRid};
    resultAjax(p_path+"/settings/pipe/inspSegement/havePiggingStructureByVR.json",
        data,function(data,obj){
            var list =fromPiggingStructureId=data.result.list;
            var html="";var html2='<li ><a href="javascript:void(0);" id="">--请选择--</a></li>';
            if(list.length>0){
                for(var i in list){
                    var fromPiggingStructureId=list[i].ID_;
                    var fromPiggingStructureName=list[i].PIGGINGSTRUCTURE_NUMBER;
                    html += '<li ><a href="javascript:void(0);" id="'+ fromPiggingStructureId +'">'+ fromPiggingStructureName +'</a></li>';
                };
                $("#"+id+"Div").html(html2);
            }else{
                $("#"+id+"Div").html(html2);
            }
            $("#"+id).html(html);//收发球桶
        },"JSON",$(this));
}
//新增、修改检测管段数据
function saveInspSegmentDate(){
    $("#addInspSegment").click(function(){
        //新增
        var lineNameId=$("#jcgdmc").children().attr("id");//管道名称id
        var inspSegmentName=$("#inspSegmentName").val();//检测管段name
        var inspSegmentAbridge=$("#inspSegmentAbridge").val();//检测管段代号
        var fromPipeValveroomId=$("#qsczfs").children().attr("id");// 起始场站阀室
        var toPipeValveroomId=$("#zdczfs").children().attr("id");// 终止场站终室
        var fromPiggingStructureId=$("#fromPiggingStructureDiv").find("a").attr("id");//发球筒
        var toPiggingStructureId=$("#toPiggingStructureDiv").find("a").attr("id");//收球筒
        var dataIds=myTableOpt_.getCheckBoxValues($("#inspSegmentListByLine"));
        var data={"id":$("#jcgdID").val(),"lineNameId":lineNameId,"inspSegmentName":inspSegmentName,"inspSegmentAbridge":inspSegmentAbridge,"fromPipeValveroomId":fromPipeValveroomId,"toPipeValveroomId":toPipeValveroomId,
            "fromPiggingStructureId":fromPiggingStructureId,"toPiggingStructureId":toPiggingStructureId,"dataIds":dataIds}
        //判断必选、必填项
        if(validateByClass("inspNotNull")){
            if(fromPipeValveroomId==toPipeValveroomId){
                alert("起始场站阀室不能与终点场站阀室相同");
                return;
            }else{
                resultAjax(p_path+"/settings/pipe/inspSegement/addInspSegment.json",
                    data,function(data,obj){
                        $("#add-jcgdlb").modal("hide");
                        alert(data.message);
                        cleanVal();//清空弹出框
                        getInspSegmentData();

                        $('.ul-main .set-ul').eq(1).removeclass('none');
                        $('.ul-main .set-ul').eq(1).siblings().addClass('none')
                    },"JSON",$(this));
            }
        }
    });
}
//检测管段单一删除
function deletInspSegmentOne(){
    //获得id delet1 deleteRoomOne
    $(".deleteInspSegmentOne").live("click",function(){
        var id=$(this).attr("id");
        var stated=$(this).attr("stated");
        var delFlag = window.confirm("确定要删除吗");
        if(delFlag==true){
            var del=stated;//数据为未发布数据，真删除
            var data={"ids":id};
            resultAjax(p_path+"/settings/pipe/inspSegement/deleteInspSegment.json",
                data,function(data,obj){
                    getInspSegmentData();
                    alert("删除成功!");
                },"JSON");
        }
    });

}
//检测管段批量删除
function deleteInspSegmentData(){
    $("#delInspSegment").click(function(){
        //找到所有class为active的选项
        var ids=new Array();
        $(".table-ck .InspSegmentChildSelect i.active").each(function(){
            ids.push($(this).attr("id"));
        });
        if(ids.length < 1){
            alert("请先勾选需要删除的任务");
            return ;
        }
        var idss=ids.join();
        var data={"ids":idss};
        var delFlag = window.confirm("确定要删除吗");
        if(delFlag == true){
            var url = p_path+"/settings/pipe/inspSegement/deleteInspSegment.json";
            $.ajax({
                url:url,
                type:'post',
                dataType:'json',
                data:data,
                success:function(data){
                    getInspSegmentData();
                    alert(data.message);
                }
            });
        }
    });
}

//检测管段任务状态修改（发布）
function toUpdateInspSegmentStated(){
    $("#updInspStated").live("click",function(){
        var ids=new Array();
        $(".table-ck .InspSegmentChildSelect i.active").each(function(){
            ids.push($(this).attr("id"));
        });
        if(ids.length < 1){
            alert("请先勾选需要发布的任务");
            return ;
        }

        var idss=ids.join();
        var data={"ids":idss};
        var updFlag = window.confirm("确定要发布吗");
        if(updFlag == true){
            var url = p_path+"/settings/pipe/inspSegement/updateInspSegmentStated.json";
            $.ajax({
                url:url,
                type:'post',
                dataType:'json',
                data:data,
                success:function(data){
                    getInspSegmentData();
                    alert(data.message);
                }
            });
        }
    })
};

//检测管段复选框文本代码(perant)
function IsegmentCheckBoxFormatP(data){
    var ck="<span class=\"table-ck\"><span class=\"check-box selected InspSegmentParentSelect\" onclick=\"\" id=\"InspSegmentParentSelect\"><i class=\"parentSelect4\"></i></span></span>";
    return ck;
}
//检测管段复选框文本代码
function IsegmentCheckBoxFormat(data){
    var ck="<span class=\"table-ck\"><span class=\"check-box selected InspSegmentChildSelect\" onclick=\"\" id="+data.ID_+"><i class=\"childSelect4\" id="+data.ID_+"></i></span></span>";
    return ck;
}
//检测管段编辑、删除部分
function deleteFormatByInspSegment(data){
    var de="<a onclick='editInspSegment(this)' data-toggle=\"modal\" class=\"edit0\" id="+data.ID_+" stated="+data.DATA_STATED+" href=\"#add-jcgdlb\"></a><a href=\"javascript:void(0);\"  class=\"delet1 deleteInspSegmentOne\" id="+data.ID_+" stated="+data.DATA_STATED+"></a>";
    return de;
}
//检测管段初始化：任务启用及停用
function toOffInspSegment(_status,m){
    var ids=new Array();
    $(".table-ck .InspSegmentChildSelect i.active").each(function(){
        ids.push($(this).attr("id"));
    });
    if(ids.length < 1){
        alert("请先勾选任务");
        return ;
    }
    var err=new Array();
    if (ids.length ==1){
        var option1 = $("#basicInspS").data("option");
        var tabData=option1.allData;
        for (var i1 in ids){
            for (var i2 in tabData){
                if (ids[i1]==(tabData[i2]["ID_"])){
                    if ((tabData[i2]["DATA_STATED"])!="20"){
                        err.push((tabData[i2]["INSP_SEGMENT_NAME"]))
                    }
                }
            }
        }
    }

    if (err.length>0){
        alert("未发布，不能启用。");
        return;
    }
    var idss=ids.join();
    var data={"ids":idss,status:_status};
    resultAjax(p_path+"/settings/pipe/inspSegement/updateInspSegmentS.json",
        data,function(data,obj){getInspSegmentData();alert("已选择"+ids.length+"条数据，"+m+data.message); },"JSON");
}
//点击新建按钮，给弹出框下拉菜单初始化值
function saveByInspSegment(){
    $("#saveInspSegment").click(function(){
        $("#jcPopupTitle").html("新增检测管段");
        $("#jcgdID").val("");
        $("#inspSegmentListByLine").html('');
        initInspSeg();
        cleanVal();//清空弹出框
    })
};
function initInspSeg(){
    xgxjgd();
    $("#jcgdID").val("");
    //请求管道名称、场站阀室
    resultAjax(p_path+"/settings/pipe/inspSegement/findPipeLine.json",
        "",function(data,obj){
            //console.log(data.result.model.lineData);
            var lineData=data.result.model.lineData;
            var valRoom=data.result.model.valveRoomData;
            var html="";var html2="";var html3=""; var html4="";
            html += '<li  ><a href="javascript:void(0);" id="">--请选择管道--</a></li>';
            for(var i in lineData){
                var lineId=lineData[i].ID_;
                var lineName=lineData[i].NAME_;
                html += '<li onclick=getInsSegByLine(\''+lineId+'\') ><a href="javascript:void(0);" id="'+ lineId +'">'+ lineName +'</a></li>';

            };
            for (var i in valRoom){
                var fromPipeValveroomId=valRoom[i].ID_;
                var fromPipeValveroomName=valRoom[i].NAME_;
                html2 += '<li onclick="getPiggingStructureByVR(\''+ fromPipeValveroomId +'\',\'fromPiggingStructure\')"><a href="javascript:void(0);" id="'+ fromPipeValveroomId +'">'+ fromPipeValveroomName +'</a></li>';
                html3 += '<li onclick="getPiggingStructureByVR(\''+ fromPipeValveroomId +'\',\'toPiggingStructure\')"><a href="javascript:void(0);" id="'+ fromPipeValveroomId +'">'+ fromPipeValveroomName +'</a></li>';
                html4 += '<li ><a href="javascript:void(0);" id="'+ fromPipeValveroomId +'">'+ fromPipeValveroomName +'</a></li>';

            }
            $("#ISLineId").html(html);//管道
            $("#FClineNameUl").html(html);
            $("#xzSegmentLineDataUl").html(html);

            $("#FValRoom").html(html2);//起始阀室
            $("#TValRoom").html(html3);//终点阀室
            $("#xzqszcfsLi").html(html4);
            $("#xzzdzcfsList").html(html4);

            $("#xzSegmentFVRUL").html(html4)
            $("#xzSegmentTVRUL").html(html4)

        },"JSON",$(this));
}

//获得所有的检测管段数据[]
//检测管段条件查询
function findByInspSegmentConditions(){
    var inspSegmentName=$("#FISCsegmentName").val();//管道名称id
    var taskStatus=$("#findISSsta").children().attr("value");
    var status=$("#findISsta").children().attr("value");
    allData={"inspSegmentName":inspSegmentName,"taskStatus":taskStatus,"status":status};
    $("#basicInspS").selectDataAfterSetParm(allData);
}
function getInspSegmentData(){
        var column=[
            {title:IsegmentCheckBoxFormatP,name:"ID_",width:"5%",align:"center",format:IsegmentCheckBoxFormat},
            // {title:"序号",name:"",width:"10%",align:"center"},
            {title:"管道名称",name:"PPLNAME",width:"10%",align:"center"},
            {title:"检测管段名称",name:"INSP_SEGMENT_NAME",width:"10%",align:"center"},
            {title:"检测管道代号",name:"ABRIDGE",width:"10%",align:"center"},
            {title:"起始场站阀室",name:"PPVFNAME",width:"10%",align:"center"},
            {title:"起始收发球装置",name:"PPPFNUM",width:"10%",align:"center"},
            {title:"终止场站阀室",name:"PPVTNAME",width:"10%",align:"center"},
            {title:"终止收发球装置",name:"PPPTNUM",width:"10%",align:"center"},
            {title:"任务状态",name:"",width:"8%",align:"center",format:dataStatedFormat},
            {title:"状态",name:"",width:"7%",align:"center",format:inspSegmentStatFormat},
            {title:"编辑 删除",name:"",width:"10%",align:"center",format:deleteFormatByInspSegment}
        ];
        $('#basicInspS').initTable({
            url:p_path+"/settings/pipe/inspSegement/findByCondition.json",
            columnData:column,
            selectDataNow:true,
            isBindDataToTr:true,
            onlyFirstPage: true,
            autoCheckBox:false
        });
    }


//===========================================================
resultAjax=function(url,data,m_fun,type,result){
    var conf={"stringFormat":true};
    $().invoke(url,data,[function(m,r){
        if (type=='JSON'||type=='json'){
            r=jQuery.parseJSON(r);
        }
        if (Base.isArray(m_fun)){
            m_fun[0].apply(self, [r,result] );
        }else {
            m_fun.apply(self, [r,result] );
        }

    }],conf);
    return;
};
